package cn.com.sbell.vss.csg.vap;

import org.dom4j.Element;

import cn.com.sbell.vss.VssConstants;
import cn.com.sbell.vss.VssException;
import cn.com.sbell.vss.csg.vap.bean.CameraHide;
import cn.com.sbell.vss.csg.vsclient.VsClient;
import cn.com.sbell.vss.csg.vsclient.util.PropertiesHolder;

public class GetHideImageArea extends ProtectedVsCommander {

	protected Element executeCommand(VsClient vsClient,
			PropertiesHolder holder, Element root) {
		Integer cameraNumber = holder.getIntProperty("cameraNumber");
		if (cameraNumber == null) 
			throw new VssException(VssConstants.CODE_REQUIRED,
					new String[] { "csg.cameraNumber"  });
		
		CameraHide cameraHideImage = vsClient.getHideImageArea(cameraNumber.intValue());
		CameraHide.HideImageArea[] hideImageAreas = cameraHideImage.getHideImageAreas();
		for (int i = 0; i < hideImageAreas.length; i++) {
			Element hideIamgeAreaElm = root.addElement("hideImageArea");
			hideIamgeAreaElm.addElement("cameraNumber").addText(cameraHideImage.getCameraNumber().toString());
			hideIamgeAreaElm.addElement("x").addText(hideImageAreas[i].getX().toString());
			hideIamgeAreaElm.addElement("y").addText(hideImageAreas[i].getY().toString());
			hideIamgeAreaElm.addElement("width ").addText(hideImageAreas[i].getWidth().toString());
			hideIamgeAreaElm.addElement("height ").addText(hideImageAreas[i].getHeight().toString());	
		}
		return root;
	}

}
